From: Jan Beulich Date: Fri, 28 Mar 2014 12:36:19 +0000 (+0100) Subject: x86/p2m: make p2m_change_type() behavior match p2m_change_entry_type_global()'s X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5330 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=e5ae6eefdfbc1816b050d02998f69f0b78d5c814;p=xen.git x86/p2m: make p2m_change_type() behavior match p2m_change_entry_type_global()'s - don't reset access permissions - don't shatter super pages Signed-off-by: Jan Beulich Reviewed-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ee527da25e..ec08e18fd3 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -693,8 +693,7 @@ p2m_type_t p2m_change_type(struct domain *d, unsigned long gfn, return pt; } -/* Modify the p2m type of a range of gfns from ot to nt. - * Resets the access permissions. */ +/* Modify the p2m type of a range of gfns from ot to nt. */ void p2m_change_type_range(struct domain *d, unsigned long start, unsigned long end, p2m_type_t ot, p2m_type_t nt) @@ -710,11 +709,29 @@ void p2m_change_type_range(struct domain *d, p2m_lock(p2m); p2m->defer_nested_flush = 1; - for ( gfn = start; gfn < end; gfn++ ) + for ( gfn = start; gfn < end; ) { - mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL); + unsigned int order; + + mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, &order); + while ( order > PAGE_ORDER_4K ) + { + if ( pt != ot ) + break; + if ( !(gfn & ((1UL << order) - 1)) && + end > (gfn | ((1UL << order) - 1)) ) + break; + if ( order == PAGE_ORDER_1G ) + order = PAGE_ORDER_2M; + else + order = PAGE_ORDER_4K; + } if ( pt == ot ) - set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, p2m->default_access); + set_p2m_entry(p2m, gfn, mfn, order, nt, a); + gfn += 1UL << order; + gfn &= -1UL << order; + if ( !gfn ) + break; } p2m->defer_nested_flush = 0;